package com.recruit.wechat.controller;


import com.recruit.wechat.controller.model.ApiResultModel;
import org.springframework.web.bind.annotation.RequestMapping;
import com.recruit.wechat.bean.result.ResultPage;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;

import com.recruit.wechat.bean.WechatWork;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 肖守凯
 * @since 2020-08-24
 */
@Controller
@RequestMapping("/WeChatUser/wechatWork")
public class WechatWorkController extends BaseController{
     /** 主页面 */
    @RequestMapping("admin/main.html")
    public String main(){
       return  "Wechatwork/WechatworkMain";
    }
    /** 添加页面跳转
     * @return 返回页面
     */
    @RequestMapping(value = "admin/addWechatWorkHtml")
    public String addWechatWorkHtml( ){
             return "Wechatwork/WechatworkAdd";
    }
    /** 编辑页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "admin/editWechatWorkHtml")
    public String editWechatWorkHtml(Integer id ,Model model ){
           model.addAttribute("wechatWork",wechatWorkService.selectWechatWorkByIdWechatWork(id));
             return "Wechatwork/WechatworkEdit";
    }

    /** 查看页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "admin/showWechatWorkHtml")
    public String showWechatWorkHtml(Integer id ,Model model ){
           model.addAttribute("wechatWork",wechatWorkService.selectWechatWorkByIdWechatWork(id));
             return "Wechatwork/WechatworkShow";
    }


    /** 分页查询WechatWork
     * @param page  页码
     * @param limit  查几条
     * @param wechatWork  前端传进的参数
     * @return 返回统一分页信息
     */
    @RequestMapping(value = "admin/findWechatWorkByPage")
    @ResponseBody
    public ResultPage findWechatWorkByPage(Integer page, Integer limit,WechatWork wechatWork){
             return wechatWorkService.findWechatWorkByPage(page,limit,wechatWork);
    }

    /** 添加WechatWork
     * @param wechatWork  前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/addWechatWork")
    @ResponseBody
    public ApiResultModel saveWechatWork(WechatWork wechatWork  ){
             return wechatWorkService.addWechatWork(wechatWork);
    }

    /** 编辑WechatWork
     * @param wechatWork  前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/editWechatWork")
    @ResponseBody
    public ApiResultModel editWechatWork(WechatWork wechatWork  ){
             return wechatWorkService.editWechatWork(wechatWork);
    }



    /** 删除一条WechatWork
     * @param id  前端传进的ID
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/delWechatWork")
    @ResponseBody
    public ApiResultModel delWechatWork( Integer id  ){
             return wechatWorkService.delWechatWork(id);
    }


}
